home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Reference Guide
/
C-C++ Interactive Reference Guide.iso
/
c_ref
/
csource5
/
376_01
/
os2tool.000
/
DIRS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-23
|
2KB
|
91 lines
/*
* DIRS.C - Print the directory stack from dirserver.
*
*
* PROGRAMMER: Martti Ylikoski
* CREATED: 29.3.1991
*/
static char *VERSION = "Version 1.0" ;
/*
*/
static char *progname ;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INCL_KBD
#define INCL_DOS
#include <os2.h>
#include "queue.h"
typedef struct kbdpacket
{
unsigned monflags ;
KBDKEYINFO kbdkeyinfo ;
unsigned ddflags ;
} KBDBUF ;
KBDBUF kbdbuf ;
//int send_queue(char *queue_name, char *message, USHORT cbElement, USHORT usRequest) ;
int main(int argc, char *argv[])
{
HQUEUE hdirsresp ; /* queuehandle */
USHORT ret ;
int i ;
QUEUERESULT qres ;
PVOID pmesg ;
USHORT cbElement ;
BYTE bElemprty ;
char *ptmp ;
SEL ginfo, linfo ;
LINFOSEG FAR *plis ;
char sga[4], queue_name[80] ;
progname = argv[0] ;
if (argc == 2 && (strcmpi(argv[1], "-q") == 0
|| strcmpi(argv[1], "/q") == 0))
{
QueSend("\\queues\\popreq", " ", 3, 1,"START /C dirserv.exe",progname) ; /* send EXIT command */
printf("Directory stack server removed. \n") ;
return( 0 ) ;
}
if (( ret = DosGetInfoSeg(&ginfo, &linfo)) != 0)
{
printf("%s: error in DosGetInfoSeg", progname) ;
return(1) ;
}
plis = MAKEPLINFOSEG(linfo) ;
itoa(plis->sgCurrent, sga, 10) ;
strcpy(queue_name, "\\queues\\sg") ; /* sg prefix - somebody might use PIDs
as a name base. We want to minimize
risk for a name clash */
strcat(queue_name, sga) ;
if (( ret = DosCreateQueue(&hdirsresp, QUE_FIFO, queue_name)) != 0)
{
fprintf(stderr, "%s: error creating queues...\Exiting...\n", progname ) ;
return( 1 ) ;
}
QueSend("\\queues\\popreq", sga, strlen(sga)+1, 2, "START /C dirserv.exe",progname ) ; /* send DIRS-command */
while (( ret = DosReadQueue(hdirsresp, &qres, &cbElement, &pmesg, 0, DCWW_WAIT,
&bElemprty, NULL)) == 0 && qres.usEventCode != 3)
{
ptmp = (char *) pmesg ;
printf("%s\n", ptmp) ;
DosFreeSeg(SELECTOROF(pmesg)) ;
}
ptmp = (char *) pmesg ;
printf("%s\n", ptmp) ;
DosCloseQueue(hdirsresp) ;
return( 0 ) ;
}